package com.yx.enterresourceplanning.controller;

import com.yx.enterresourceplanning.entity.Dto.UserFormDto;
import com.yx.enterresourceplanning.service.UserFormService;
import com.yx.enterresourceplanning.utils.ResponseCode;
import com.yx.enterresourceplanning.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/userform")
public class UserFormController {
    @Autowired
    private UserFormService userFormService;
    @PostMapping("/notodo")
    public Result<List<UserFormDto>> getStateFormOfNotTodoByUserId(@RequestParam(name = "userId") String userId){
        //根据用户id获取不是待办的验收单方法。
        return Result.success(ResponseCode.SUCCESS, userFormService.getStateFormOfNotTodoByUserId(userId));
    }
    @PostMapping("/updateState")
    public Result<Boolean> updateState(@RequestParam(name = "formId") String formId, @RequestParam(name = "userId") String userId, @RequestParam(name = "state") String state){
        return Result.success(ResponseCode.SUCCESS, userFormService.updateState(formId, userId, state));
    }
    @PostMapping("/show")
    public Result<List<UserFormDto>> getDiffFormByUserIdAndState(@RequestParam(name = "userId") String userId, @RequestParam(name = "state") String state){
    return Result.success(ResponseCode.SUCCESS, userFormService.getDiffFormByUserIdAndState(userId, state));
    }
    @PostMapping("/getStateByUserIdAndFormId")
    public Result<Integer> getStateByUserIdAndFormId(@RequestParam(name = "userId") String userId, @RequestParam(name = "formId") String formId){
        return Result.success(ResponseCode.SUCCESS, userFormService.getStateByUserIdAndFormId(userId, formId));
    }
}
